﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Configuration;
using Windows.UI.Xaml.Controls;

namespace BoolanElement
{
    public static  class ShapesFacotry
    {
        public static BooUIBase CreateShapes(string type)
        {
            //var config = (await ShapesConfig.GetShapesConfig()).Root.Element(type);

            BooUIBase uiReturn = null;

            switch(type)
            {
                case "Line": uiReturn = new BooLine(BooLineElement.InitLineStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                   break;
                case "Arrow": uiReturn = new BooArrow(BooArrowElement.InitLineStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "Rectangle": uiReturn = new BooRectangle(BooRectangleElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "RoundRect": uiReturn = new BooRoundedRectangle(BooRoundRectElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo); 
                    break;
                case "Ellipse": uiReturn = new BooEllipse(BooEllipseElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo); 
                    break;
                case "Triangle": uiReturn = new BooTriangle(BooTriangleElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "RightTriangle": uiReturn = new BooRightTriangle(BooRightTriangleElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo); 
                    break;
                case "Pentagon": uiReturn = new BooPentagon(BooPentagonElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "RightArrow": uiReturn = new BooRightArrow(BooRightArrowElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo); 
                    break;
                case "TwoArrows": uiReturn = new BooTwoArrows(BooTwoArrowsElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "Diamond": uiReturn = new BooDiamond(BooDiamondElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "RoundRectDialog": uiReturn = new BooRectangleDialog(BooRectangleDialogElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "EllipseDialog": uiReturn = new BooEllipseDialog(BooEllipseDialogElement.InitElementStyle(),
                     Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo); 
                     break;
                case "FivePointed": uiReturn = new BooFivePointed(BooFivePointedElement.InitElementStyle(),
                    Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                case "Curve": uiReturn = new BooCurve(BooCurveElement.InitCurveStyle(),
                     Configuration.GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo);
                    break;
                default: uiReturn = null; break;
            }
            if (uiReturn != null)
            {
                uiReturn.saveForRedoUndo = GlobalVariable.OpenedDocument.Slides[GlobalVariable.CurrentShowIndex].SaveForRedoUndo;
            }
            return uiReturn;
        }
    }
}
